package com.ruoyi.web.controller.user;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Photographer;
import com.ruoyi.system.service.IPhotographerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 摄影师信息Controller
 * 
 * @author Eugene
 * @date 2023-04-14
 */
@Api(tags = "摄影师信息")
@RestController
@RequestMapping("/photographer/photographer")
public class PhotographerController extends BaseController
{
    @Autowired
    private IPhotographerService photographerService;

    /**
     * 查询摄影师信息列表
     */
    @ApiOperation("查询摄影师信息列表")
    @PreAuthorize("@ss.hasPermi('photographer:photographer:list')")
    @GetMapping("/list")
    public TableDataInfo list(Photographer photographer)
    {
        startPage();
        List<Photographer> list = photographerService.selectPhotographerList(photographer);
        return getDataTable(list);
    }

    /**
     * 导出摄影师信息列表
     */
    @PreAuthorize("@ss.hasPermi('photographer:photographer:export')")
    @Log(title = "摄影师信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Photographer photographer)
    {
        List<Photographer> list = photographerService.selectPhotographerList(photographer);
        ExcelUtil<Photographer> util = new ExcelUtil<Photographer>(Photographer.class);
        util.exportExcel(response, list, "摄影师信息数据");
    }

    /**
     * 获取摄影师信息详细信息
     */
    @ApiOperation("获取摄影师信息详细信息")
    @PreAuthorize("@ss.hasPermi('photographer:photographer:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(photographerService.selectPhotographerById(id));
    }

    /**
     * 新增摄影师信息
     */
    @ApiOperation("新增摄影师信息")
    @PreAuthorize("@ss.hasPermi('photographer:photographer:add')")
    @Log(title = "摄影师信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Photographer photographer)
    {
        return toAjax(photographerService.insertPhotographer(photographer));
    }

    /**
     * 修改摄影师信息
     */
    @ApiOperation("修改摄影师信息")
    @PreAuthorize("@ss.hasPermi('photographer:photographer:edit')")
    @Log(title = "摄影师信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Photographer photographer)
    {
        return toAjax(photographerService.updatePhotographer(photographer));
    }

    /**
     * 删除摄影师信息
     */
    @ApiOperation("删除摄影师信息")
    @PreAuthorize("@ss.hasPermi('photographer:photographer:remove')")
    @Log(title = "摄影师信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(photographerService.deletePhotographerByIds(ids));
    }
}
